package com.ikangtai.shecare.curve;

import android.content.Context;
import android.content.Intent;
import android.webkit.JavascriptInterface;

import com.ikangtai.shecare.common.util.AppLog;
import com.ikangtai.shecare.knowledge.ArticleActivity;
import com.ikangtai.shecare.knowledge.ArticleListActivity;
import com.ikangtai.shecare.knowledge.BannerActivity;

public class OnChartClickListener{
    private Context context;

    public OnChartClickListener(Context context){
        this.context = context;
    }

    @JavascriptInterface
    public void openChartActivity(String className){
        Intent intent = new Intent();
        try{
            intent.setClass(context, Class.forName(className));
            context.startActivity(intent);
        }catch(ClassNotFoundException e){
            // do Nothing
        }
    }

    @JavascriptInterface
    public void openArticleListActivity(String articleListId){
        AppLog.i("openArticleListActivity! clicked articleListId = " + articleListId);
        Intent intent = new Intent();
        intent.putExtra("articleListId", articleListId);

        intent.setClass(context, ArticleListActivity.class);
        context.startActivity(intent);
    }

    @JavascriptInterface
    public void openArticleActivity(String articleId){
        AppLog.i("openArticleActivity! clicked articleId = " + articleId);
        Intent intent = new Intent();
        intent.putExtra("articleId", articleId);

        intent.setClass(context, ArticleActivity.class);
        context.startActivity(intent);

    }

    @JavascriptInterface
    public void openBannerActivity(String url) {
//        if(TextUtils.equals(activityName, "banner")){
//            context.startActivity(new Intent(context,BannerActivity.class));
//        }else{
//        }
        Intent intent = new Intent();
        intent.putExtra("url", url);

        intent.setClass(context, BannerActivity.class);
        context.startActivity(intent);
    }
}